//package com.vast.admin.service.impl;
//
//import cn.hutool.core.date.DateTime;
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import com.vast.admin.entity.RoleDept;
//import com.vast.admin.mapper.RoleDeptMapper;
//import com.vast.admin.service.RoleDeptService;
//import com.vast.system.shiro.ShiroUtils;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.List;
//
//@Service
//public class RoleDeptServiceImpl extends ServiceImpl<RoleDeptMapper, RoleDept> implements RoleDeptService{
//
//    @Override
//    @Transactional(rollbackFor = Exception.class)
//    public boolean  addOrUpdate(Long roleId, Long[] deptIdList) {
//        //先删除角色与部门关系
//        deleteBatch(new Long[]{roleId});
//
//        if(deptIdList == null || deptIdList.length == 0){
//            return true;
//        }
//
//        //保存角色与部门关系
//        for(Long deptId : deptIdList){
//            RoleDept roleDept = new RoleDept();
//            roleDept.setDeptId(deptId);
//            roleDept.setRoleId(roleId);
//            roleDept.setCreateBy(ShiroUtils.getUserId());
//            roleDept.setCreateTime(DateTime.now());
//            roleDept.setUpdateBy(ShiroUtils.getUserId());
//            roleDept.setUpdateTime(DateTime.now());
//            this.save(roleDept);
//        }
//        return true;
//    }
//
//    @Override
//    public List<Long> queryDeptIdList(Long[] roleIds) {
//        return null;
//    }
//
//    @Override
//    public int deleteBatch(Long[] roleIds) {
//        return baseMapper.deleteBatch(roleIds);
//    }
//
//    @Override
//    public int deleteRoleDeptByRoleId(Long roleId) {
//        return baseMapper.delete(new QueryWrapper<RoleDept>().eq(RoleDept.COL_ROLE_ID,roleId));
//    }
//}
